package top.kaoshanji.q1ch06c;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import top.kaoshanji.q1ch06c.config.ProjectConfig;
import top.kaoshanji.q1ch06c.model.Comment;
import top.kaoshanji.q1ch06c.services.CommentService;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/4/29 10:28
 */
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {ProjectConfig.class})
public class AppTests {

    @Autowired
    private CommentService commentService;

    /**
     * 代码清单test-q1ch06c-01：测试一下修改目标方法返回值
     */
    @Test
    public void testAspectInterceptsPublishCommentMethod() {

        Comment comment = new Comment();
        comment.setText("Test comment text");
        comment.setAuthor("Test comment author");

        String result = commentService.publishComment(comment);

        Assertions.assertEquals("FAILED", result);
    }

}
